import {req_delete, req_get, req_post} from "@/request/cssdrequest";
import {R} from "@/type/dto/R";
import {RP} from "@/type/dto/RP";
import {DictInfoVO} from "@/type/vo/DictInfoVO";
import {DictQueryDto} from "@/type/dto/DictQueryDto";

export async function api_getPageListDict(dictQueryDto: DictQueryDto) {

    const data = await req_get('/assistant/dict/page', dictQueryDto);
    //转成我要的json
    console.log('data:', data);
    return JSON.parse(data) as R<RP<DictInfoVO>>;
}

export async function api_getListDict(dictType: string) {

    const data = await req_get('assistant/dict/list', {
        dictType
    });
    //转成我要的json
    console.log('data:', data);
    return JSON.parse(data) as R<Array<DictInfoVO>>;
}

export async function api_addDict(dictQueryDto: DictQueryDto) {

    const data = await req_post('assistant/dict', dictQueryDto);
    //转成我要的json
    console.log('data:', data);
    return JSON.parse(data) as R<string>;
}

export async function api_deleteDict(id: string) {

    const data = await req_delete('assistant/dict', {id});
    //转成我要的json
    console.log('data:', data);
    return JSON.parse(data) as R<string>;
}